<?php

class News_model extends CI_Model {

    private $_table = 'articles';
    private $_where = array(
        'type'  =>  TYPE_ARTICLE
    );
    public function get_news($params) {
        $where = array_merge($this->_where, array(
        ));
        $query = $this->db->get_where($this->_table, $where, PER_PAGE, $params['offset']);
        return $query->result_array();
    }

    public function get_new($params) {
        $where = array_merge($this->_where, array(
            'id'    =>  $params['id']
        ));
        $query = $this->db->get_where($this->_table, $where);
        return $query->row();
    }

    public function get_num_rows($params = array()) {
        $where = array_merge($this->_where, array(
        ));
        $query = $this->db->get_where($this->_table, $where);
        return $query->num_rows();
    }
    public function get_top_news() {
        $where = array_merge($this->_where, array(
        ));
        $query = $this->db->get_where($this->_table, $where, TOP_ITEMS);
        return $query->result_array();
    }
    public function get_top_other_news() {
        $where = array_merge($this->_where, array(
        ));
        $query = $this->db->get_where($this->_table, $where, TOP_OTHER_ITEMS);
        return $query->result_array();
    }
}
